package com.learn.spring.service;

import com.learn.spring.dao.IAnnotationDemoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

// 在注解里面 value 属性值可以省略不写,默认值是类名称，首字母小写;
// 如: annotationDemoService
//@Component(value = "demoService")
@Service(value = "demoService")
public class AnnotationDemoService {

//    @Autowired
//    @Qualifier(value = "annotationDemoDao") // 如果一个接口有两个实现类时,实用类型自动装配就会出问题，必须实用名称自动装配。
//    @Resource
    @Resource(name = "annotationDemoDao")
    private IAnnotationDemoDao demoDao;

    @Value(value = "summer")
    private String name;

    public void show() {
        System.out.println("AnnotationDemoService");
    }

    public void info() {
        System.out.print(name + ":");
        demoDao.info();
    }

}
